﻿@model ProductModel
@{
    var defaultGridPageSize = EngineContext.Current.Resolve<Nop.Core.Domain.Common.AdminAreaSettings>().DefaultGridPageSize;
    var gridPageSizes = EngineContext.Current.Resolve<Nop.Core.Domain.Common.AdminAreaSettings>().GridPageSizes;
}
<p>
    @T("Admin.Catalog.Products.PurchasedWithOrders.Hint")
</p>


<div id="purchased-with-orders-grid"></div>

<script>
    $(document).ready(function () {
        $("#purchased-with-orders-grid").kendoGrid({
            dataSource: {
                type: "json",
                transport: {
                    read: {
                        url: "@Html.Raw(Url.Action("PurchasedWithOrders", "Product", new { productId = Model.Id }))",
                        type: "POST",
                        dataType: "json"
                    }
                },
                schema: {
                    data: "Data",
                    total: "Total",
                    errors: "Errors"
                },
                error: function(e) {
                    display_kendoui_grid_error(e);
                    // Cancel the changes
                    this.cancelChanges();
                },
                pageSize: @(defaultGridPageSize),
                serverPaging: true,
                serverFiltering: true,
                serverSorting: true
            },
            pageable: {
                refresh: true,
                pageSizes: [@(gridPageSizes)]
            },
            editable: {
                confirmation: false,
                mode: "inline"
            },
            scrollable: false,
            columns: [{
                    field: "Id",
                    title: "@T("Admin.Orders.Fields.ID")",
                    width: 50
                }, {
                    field: "CustomerEmail",
                    title: "@T("Admin.Orders.Fields.CustomerEmail")",
                    width: 200
                },
                @if (!Model.IsLoggedInAsVendor)
                {
                    <text>{
                field: "OrderStatus",
                                        title: "@T("Admin.Orders.Fields.OrderStatus")",
            width: 100
            },{
                field: "PaymentStatus",
                title: "@T("Admin.Orders.Fields.PaymentStatus")",
            width: 100
                },{
                    field: "ShippingStatus",
                    title: "@T("Admin.Orders.Fields.ShippingStatus")",
            width: 100
        },</text>
                }
            
            {
                field: "CreatedOn",
                title: "@T("Admin.Orders.Fields.CreatedOn")",
                width: 200,
                type: "date",
                format: "{0:G}"
            }]
        },
        {
            field: "Id",
            title: "@T("Admin.Common.View")",
            width: 200,
            template: '<a href="@Url.Content("~/Admin/Order/Edit/")#=Id#">@T("Admin.Common.View")</a>'
        });
    });
</script>